//
//  ICMCarePackageModel.m
//  ICrEAM
//
//  Created by rainimute on 16/11/9.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMCarePackageModel.h"

@implementation ICMCarePackageModel

- (void)setupCarePackageModelWithPackageView:(ICMCarePackageView *)packageView{
    self.TT_RECPTION_PACKAGE_ITEM = packageView.careSelectedItems;
}

- (void)createCarePackageItemModel{
    NSMutableArray *array = [NSMutableArray array];
    for (NSDictionary *dic in self.TT_RECPTION_PACKAGE_ITEM) {
        ICMCarePackageItemModel *model = [ICMCarePackageItemModel yy_modelWithDictionary:dic];
        NSMutableArray *sarr=[NSMutableArray array];
        for (NSDictionary *sdic in model.OIL_TYPE) {
            ICMCarePackageThree_levelItemModel *sModel=[ICMCarePackageThree_levelItemModel yy_modelWithDictionary:sdic];
            [sarr addObject:sModel];
        }
        model.OIL_TYPE=sarr;
        [array PACA_AddObject:model];
    }
    self.TT_RECPTION_PACKAGE_ITEM = array;
}

- (NSString *)PACKAGE_NAME{
    if (self.TT_RECPTION_PACKAGE_ITEM.count) {
        ICMCarePackageItemModel *model = self.TT_RECPTION_PACKAGE_ITEM[0];
        _PACKAGE_NAME = model.PACKAGE_NAME;
    }
    return _PACKAGE_NAME?:@"";
}

+ (instancetype)createCarePackageModelWithModelDic:(NSDictionary *)modelDic{
    ICMCarePackageModel *packageModel = [[ICMCarePackageModel alloc] init];
    packageModel.PACKAGE_NAME = [modelDic.allKeys firstObject];
    packageModel.TT_RECPTION_PACKAGE_ITEM = [NSMutableArray array];
    NSArray *items = [modelDic objectForKey:packageModel.PACKAGE_NAME];
    for (NSDictionary *itemDic in items) {
        ICMCarePackageItemModel *itemModel = [[ICMCarePackageItemModel alloc]init];
        itemModel.PACKAGE_ITEM_ID = itemDic[@"ITEM_ID"];
        itemModel.PACKAGE_NAME = packageModel.PACKAGE_NAME;
        itemModel.PACKAGE_ITEM_NAME = itemDic[@"ITEM_NAME"];
        
        NSMutableArray *deepArr=[NSMutableArray array];
        id types=itemDic[@"OIL_TYPE"];
        if ([types isKindOfClass:[NSArray class]]) {
               NSArray *arr=itemDic[@"OIL_TYPE"];
            for (NSDictionary *dic in arr ) {
                ICMCarePackageThree_levelItemModel *model=[[ICMCarePackageThree_levelItemModel alloc]init];
                model.OIL_NAME=dic[@"OIL_NAME"];
                model.OIL_VALUE=dic[@"OIL_VALUE"];
                [deepArr addObject:model];
            }
        }
    
        itemModel.OIL_TYPE=deepArr;
        [packageModel.TT_RECPTION_PACKAGE_ITEM PACA_AddObject:itemModel];
    }
    return packageModel;
}

@end


@implementation ICMCarePackageItemModel


@end
@implementation ICMCarePackageThree_levelItemModel


@end
